{% load ts_extras %}
<div id="ts_list" class="treeview">
    <div class="treeview-header">
    <h2>Transsys program list</h2>
    </div>
    <div class="treeview-body">
    {% if request.session.ts_programs %}
    <ul class="list-lv1">
        {% for tsp in request.session.ts_programs %}
        <li {% if tsp.tp.name == request.session.ts_program.tp.name %}
                class="active"
            {% endif %}
            >
            <div class="collapsed treeview-header">
                <a class="expand" href="#" title="expand" ></a>
                <a class="collap" href="#" title="collap" ></a>
                <h3><a title="Transsys program {{tsp.tp.name}}" href="{% url tsworkbench.views.ts.viewTP tsp.tp.name|escapeUrl %}">{{tsp.tp.name}}</a></h3>
                <a id="{% url tsworkbench.views.ts.delTP tsp.tp.name|escapeUrl %}" rev="transsys program" class="delete" href="#" title="delete" ></a>
            </div>
            <div class="expanded">
                <!-- Factor listing -->
                <div class="treeview-lv1">
                    <div class="collapsed treeview-header">
                        <h4>Factor list</h4>
                        <a class="expand" href="#" title="expand" ></a>
                        <a class="collap" href="#" title="collap" ></a>
                    </div>
                    <div class="expanded">
                    {% if tsp.tp.factor_list %}
                    <ul class="list-lv2">
                    {% for f in tsp.tp.factor_list %}
                        <li>
                            <div class="collapsed">
                                <a title="Factor {{f.name}}" href="{% url tsworkbench.views.ts.editFactor tsp.tp.name|escapeUrl f.name %}" >{{f.name}}</a>
                                <a class="expand" href="#" title="expand" ></a>
                                <a class="collap" href="#" title="collap" ></a>
                                <a id="{% url tsworkbench.views.ts.delFactor tsp.tp.name|escapeUrl f.name %}" rev="factor" class="delete" href="#" title="delete" ></a>
                            </div>
                            <div class="expanded">
                            <ul>
                                <li>Decay: {{f.decay_expression}}</li>
                                <li>Diffusibility: {{f.diffusibility_expression}}</li>
                            </ul>
                            </div>
                        </li>
                    {% endfor%}
                    </ul>
                    {%else%}
                    <p>No factors</p>
                    {%endif%}
                    </div>
                </div>
                <!-- Gene listing -->
                <div class="treeview-lv1">
                    <div class="collapsed treeview-header">
                        <h4>Gene list</h4>
                        <a class="expand" href="#" title="expand" ></a>
                        <a class="collap" href="#" title="collap" ></a>
                    </div>
                    <div class="expanded">
                {% if tsp.tp.gene_list %}
                    <ul class="list-lv2">
                    {% for g in tsp.tp.gene_list %}
                        <li>
                            <div class="collapsed">
                                <a title="Gene {{g.name}}" href="{% url tsworkbench.views.ts.editGene tsp.tp.name|escapeUrl g.name %}">{{g.name}}</a>
                                <a class="expand" href="#" title="expand" ></a>
                                <a class="collap" href="#" title="collap" ></a>
                                <a id="{% url tsworkbench.views.ts.delGene tsp.tp.name|escapeUrl g.name %}" rev="gene" class="delete" href="#" title="delete" ></a>
                            </div>
                            <div class="expanded">
                            <ul>
                                <li><label>Product:</label> {{g.product_name}}</li>
                                <li>
                                    <label>Promoters: {{g.promoter.count}}</label><br/>
                                    <ul>
                                        {% for p in g.promoter %}
                                            <li>
                                                {{p}}
                                            </li>
                                        {% endfor %}
                                    </ul>
                                </li>
                            </ul>
                            </div>
                        </li>
                    {% endfor%}
                    </ul>
                    {%else%}
                    <p>No genes</p>
                    {%endif%}
                    </div>
                </div>
            </div>
        </li>
        {% endfor %}
    </ul>
    <div class="treeview-footer">
        <a id="add_new" class="link-button" href="{%url tsworkbench.views.ts.addTranssysProgram %}" title="Add new Transsys program">Add new</a>
        <a id="upload_new" class="link-button" href="{% url tsworkbench.views.ts.uploadTranssysProgram %}" title="Upload transsys code">Upload new</a>
        <a id="export" class="link-button" href="{% url tsworkbench.views.exportWorkspace %}" title="Export workbench">Export</a>
        <a id="import" class="link-button" href="{% url tsworkbench.views.importWorkspace %}" title="Import workbench">Import</a>
    </div>
    {%else%}
    <p>No transsys program</p>
    <div class="treeview-footer">
    <a id="add_new" class="link-button" href="{%url tsworkbench.views.ts.addTranssysProgram %}" title="Add new Transsys program">Add new</a>
    <a id="upload_new" class="link-button" href="{% url tsworkbench.views.ts.uploadTranssysProgram %}" title="Upload transsys code">Upload new</a>
    <a id="export" class="link-button" href="{% url tsworkbench.views.exportWorkspace %}" title="Export workbench">Export</a>
    <a id="import" class="link-button" href="{% url tsworkbench.views.importWorkspace %}" title="Import workbench">Import</a>
    </div>
    {%endif%}
    </div>
</div>